package com.bolang.onlycode.demo.server;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Arrays;

public class IOServerDu {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(7777);
        InputStream input = null;
        OutputStream output = null;
        StringBuffer request=new StringBuffer();
        byte[] buffer=new byte[1024];

        while (true){
            Socket accept = serverSocket.accept();
            input =  accept.getInputStream();
            output =  accept.getOutputStream();
            if (input.read(buffer)>-1){
                for (int i = 0; i < buffer.length; i++) {
                    request.append((char) buffer[i]);
                }
                System.out.println("服务器收到的内容"+request);
            }
            output.write(buffer);
            output.flush();
        }




    }
}
